package org.zhs.dao;

import org.springframework.stereotype.Repository;
import org.zhs.pojo.Department;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
//相当于bean,被spring托管的类
@Repository
public class DepartmentDao {
//    没有连接数据库,采用模拟数据的形式
//    设置键,对应id字段
    private static Map<Integer, Department> departments = null;
    static {
        departments = new HashMap<>(4);
        departments.put(101, new Department(101, "教学部"));
        departments.put(102,new Department(102, "市场部"));
        departments.put(103,new Department(103, "教研部"));
        departments.put(104,new Department(104, "运营部"));
        departments.put(105,new Department(105, "后勤部"));
    }
    public Collection<Department> getDepartments(){
        return departments.values();
    }
    public Department getDepartmentById(Integer id){
        return departments.get(id);
    }
}
